package com.ea.common.util;

import com.ea.common.enums.OperationResultCode;
import com.ea.common.exception.ServiceException;

import java.lang.reflect.Field;

/**
 * @author NAME-L
 * @Description TODO
 * @className ObjectsUtil
 * @date 2023-01-15 00:46:41
 */
public class ObjectsUtil {

    public static boolean isNullObject(Object o) {
        try {
            for (Field field : o.getClass().getDeclaredFields()) {
                field.setAccessible(true);
                Object o1 = field.get(o);
                if (o1 == null) {
                    return true;
                }
            }
        } catch (Exception e) {
            throw new ServiceException(OperationResultCode.SYSTEM_ERROR.getCode(), "ObjectsUtil.isNullObject exception:" + e);
        }
        return false;
    }
}
